/*
 * @Author: your name
 * @Date: 2021-06-20 15:36:37
 * @LastEditTime: 2021-06-23 08:59:10
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \totiao\src\api\homeApi.js
 */

import request from '../utils/request'

// 获取用户频道列表的api

export const getUserChannelsApi = function () {
  return request.get('/v1_0/user/channels ')
}

// 根据频道id 和 事件戳请求文章列表数据的api
// id 是 频道的id
// time 是时间戳(首页的值是 Date.now(),其他页面的值是上次请求拿到的pre_timestamp的值)
export const getArtListApi = function (id, time) {
  return request.get('/v1_0/articles', {
    // params指向的才是get的参数对象
    params: {
      // 频道id
      channel_id: id,
      // 时间戳
      timestamp: time
    }
  })
}

// 将文章设置成不敢兴趣
// 形参中的 id是文章的id
export const NointerestApi = function (id) {
  return request.post('/v1_0/article/dislikes', {
    target: id
  })
}

// 举报文章
export const ReportanarticleApi = function (target, type) {
  return request.post('/v1_0/article/reports', { target, type })
}

// 获取所以的频道列表数据
export const getAllChennelApi = function () {
  return request.get('/v1_0/channels')
}

// 更新用户的频道数据
export const UpdateuserApi = function (channels) {
  return request.put('/v1_0/user/channels', { channels })
}
